﻿Public Class frmAlert

    Dim strNameForm As String = "Alert meeting"
    Dim intMeetingID As Integer

    Public Function Initialize(ByVal inMeetingID As Integer) As Boolean
        Try
            Me.Text = strNameForm
            intMeetingID = inMeetingID

            Return CaricaMeetingInfo()

        Catch ex As Exception
            Base.ShowError.Show("Initialize", Me.Name, "Initialize", ex)
            Return False
        End Try
    End Function

    Private Function CaricaMeetingInfo() As Boolean
        Try
            Dim oTMeetings As New Data.TMeetings
            If oTMeetings.LoadData(intMeetingID) Then
                lblShow.Text = oTMeetings.mDescription & vbCrLf &
                            oTMeetings.mDate
            Else
                Return False
            End If
            oTMeetings = Nothing

            Return True
        Catch ex As Exception
            Base.ShowError.Show("Carica meeting info", Me.Name, "CaricaMeetingInfo", ex)
            Return False
        End Try
    End Function

#Region "Commands"

    Private Sub cmdDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDone.Click
        Try
            Dim oTMeetings As New Data.TMeetings
            If oTMeetings.LoadData(intMeetingID) Then
                oTMeetings.mStatus = MEETING_STATUS_DONE.Number

                If oTMeetings.Modify() Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MsgBox("Impossibile modificare il meeting.", vbExclamation, Me.Text)
                    Me.DialogResult = Windows.Forms.DialogResult.Cancel
                End If
            Else
                MsgBox("Impossibile modificare il meeting.", vbExclamation, Me.Text)
                Me.DialogResult = Windows.Forms.DialogResult.Cancel
            End If
        Catch ex As Exception
            Base.ShowError.Show("Meeting done", Me.Name, "cmdDone_Click", ex)
        End Try
    End Sub

#End Region

#Region "Form events"

    Private Sub me_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.DialogResult = DialogResult.Cancel
        End If
    End Sub

#End Region

End Class